//测试代码使用工具

export function reactiveTest(tagNum, reactVal, time = 1000) {
  setInterval(() => {
    const tag_vm = reactVal.value[tagNum];
    tag_vm.value = incrementStringNumber(tag_vm.value);
    if (toNum(tag_vm.value) > 50 && toNum(tag_vm.value) < 70) {
      tag_vm.status = 1;
    } else if (toNum(tag_vm.value) > 70 && toNum(tag_vm.value) < 150) {
      tag_vm.status = 2;
    } else if (toNum(tag_vm.value) > 150) {
      tag_vm.value = 0;
      tag_vm.status = 0;
    }
  }, time);
}
export function toNum(str) {
  return parseInt(str, 10);
}

export function incrementStringNumber(str) {
  // Convert the string to a number
  const num = parseInt(str, 10);

  // Check if the conversion was successful
  if (isNaN(num)) {
    // throw new Error("Input must be a string containing a number");
    console.error(num, "Input must be a string containing a number");
    return "0";
  }

  // Increment the number and convert it back to a string
  return (num + 1).toString();
}
